package Servlet;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns = "/life",initParams = {@WebInitParam(name="setChar",value="uft-8")})
public class ServletLife extends HttpServlet {
	@Override
	public void init() throws ServletException {
		System.out.println("----------初始化方法------------");
	}

	public ServletLife() {
	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("-------------------服务层------------");
		System.out.println(this.getInitParameter("setChar"));
		ServletConfig config=this.getServletConfig();
		String setChar=config.getInitParameter("setChar");
		System.out.println("初始化参数值："+setChar);
	}

	@Override
	public void destroy() {
		System.out.println("-----------------销毁方法----------------");
	}
}